# -*- coding: utf-8 -*-
"""
    APF.main
    ~~~~~~~~~~~~~~
    Api插件框架
    :copyright: (c) 2018 XJJ by CornWu
"""
import sys
from flask import Flask
from flask_cors import *
from config import GLOBAL

reload(sys)
sys.setdefaultencoding('utf-8')

#初始化定义application
app = Flask(__name__)
CORS(app, supports_credentials=True)

__author__  = "CornWu"
__email__   = "CornWu@yeah.net"
__date__    = "2018-08-03"
__version__ = "1.0.0.0"

app.config['SWAGGER'] = {
    'title': GLOBAL.get('AppName'),
    'uiversion': GLOBAL.get('SwaggerUiVersion'),
    'description': GLOBAL.get('SwaggerDescription'),
    'version': __version__
}

import  sys
from core.plugin_manager import PluginManager

reload(sys)
sys.setdefaultencoding('utf-8')

#初始化插件管理器(自动扫描并加载运行)
pluginManager = PluginManager(app)

if __name__ == '__main__':
    app.run(host=GLOBAL.get('Host'), port=int(GLOBAL.get('Port')), debug=False)